package args;

public class ArgsDemo {
    public static void main(String[] args) {
        System.out.println(getSum(1, 2, 3, 4, 5));
        System.out.println(getSum(1,1,1,1));
        int[] arr = {1,2,3,4,5};
        System.out.println(getSum(arr));
    }
    //本质是把参数都存在数组中,如果还有其他参数，要把可变参数放最后
    public static int getSum(int...nums){
       int sum = 0;
       for (int num : nums) {
           sum+=num;
       }
       return sum;
    }
}
